package com.example.mobile2030606150cjk0406;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private Button btnMainNull;
    private TextView tvMainTx1;
    private RadioGroup radgupMainLine1;
    private RadioButton radbtnMainLine1;
    private RadioButton radbtnMainLine2;
    private RadioButton radbtnMainLine3;
    private RadioButton radbtnMainLine4;
    private TextView tvMainTx2;
    private RadioGroup radgupMainLine2;
    private RadioButton radbtnMainLine5;
    private RadioButton radbtnMainLine6;
    private RadioButton radbtnMainLine7;
    private RadioButton radbtnMainLine8;
    private TextView tvMainTx3;
    private RadioGroup radgupMainLine3;
    private RadioButton radbtnMainLine9;
    private RadioButton radbtnMainLine10;
    private RadioButton radbtnMainLine11;
    private RadioButton radbtnMainLine12;
    private TextView tvMainTx4;
    private RadioGroup radgupMainLine4;
    private RadioButton radbtnMainLine13;
    private RadioButton radbtnMainLine14;
    private RadioButton radbtnMainLine15;
    private RadioButton radbtnMainLine16;
    private Button btnMainSub;
    private TextView tvMainTx5;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainNull.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                radbtnMainLine1.setChecked(false);
                radbtnMainLine2.setChecked(false);
                radbtnMainLine3.setChecked(false);
                radbtnMainLine4.setChecked(false);
                radbtnMainLine5.setChecked(false);
                radbtnMainLine6.setChecked(false);
                radbtnMainLine7.setChecked(false);
                radbtnMainLine8.setChecked(false);
                radbtnMainLine9.setChecked(false);
                radbtnMainLine10.setChecked(false);
                radbtnMainLine11.setChecked(false);
                radbtnMainLine12.setChecked(false);
                radbtnMainLine13.setChecked(false);
                radbtnMainLine14.setChecked(false);
                radbtnMainLine15.setChecked(false);
                radbtnMainLine16.setChecked(false);
                Log.i("分数为", "0");
            }
        });
        btnMainSub.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int optionID1 = radgupMainLine1.getCheckedRadioButtonId();
                int optionID2 = radgupMainLine2.getCheckedRadioButtonId();
                int optionID3 = radgupMainLine3.getCheckedRadioButtonId();
                int optionID4 = radgupMainLine4.getCheckedRadioButtonId();
                if (optionID1 == R.id.radbtn_main_line1 & optionID2==R.id.radbtn_main_line7 & optionID3==R.id.radbtn_main_line10 & optionID4==R.id.radbtn_main_line13) {
                    tvMainTx5.setText("分数：100分");
                } else if (optionID1 == R.id.radbtn_main_line1 & optionID2==R.id.radbtn_main_line7 & optionID3==R.id.radbtn_main_line10 || optionID2==R.id.radbtn_main_line7 & optionID3==R.id.radbtn_main_line10 & optionID4==R.id.radbtn_main_line13 || optionID1 == R.id.radbtn_main_line1& optionID3==R.id.radbtn_main_line10 & optionID4==R.id.radbtn_main_line13) {
                    tvMainTx5.setText("分数：75分");
                }else if (optionID1 == R.id.radbtn_main_line1 & optionID2==R.id.radbtn_main_line7 || optionID1 == R.id.radbtn_main_line10& optionID3==R.id.radbtn_main_line10||optionID1 == R.id.radbtn_main_line1& optionID4==R.id.radbtn_main_line13|| optionID2==R.id.radbtn_main_line7& optionID3==R.id.radbtn_main_line10|| optionID2==R.id.radbtn_main_line7 & optionID4==R.id.radbtn_main_line13|| optionID3==R.id.radbtn_main_line10 & optionID4==R.id.radbtn_main_line13){
                    tvMainTx5.setText("分数：50分");
                }else if (optionID1 == R.id.radbtn_main_line1  || optionID2==R.id.radbtn_main_line7 || optionID3==R.id.radbtn_main_line10 || optionID4==R.id.radbtn_main_line13){
                    tvMainTx5.setText("分数：25分");
                }else if (optionID1==-1||optionID2==-1||optionID3==-1||optionID4==-1 ){
                    Toast.makeText(MainActivity.this, "请作出选择", Toast.LENGTH_SHORT).show();
                }else{
                    tvMainTx5.setText("分数：0分");
                }

            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        btnMainNull = (Button) findViewById(R.id.btn_main_null);
        tvMainTx1 = (TextView) findViewById(R.id.tv_main_tx1);
        radgupMainLine1 = (RadioGroup) findViewById(R.id.radgup_main_line1);
        radbtnMainLine1 = (RadioButton) findViewById(R.id.radbtn_main_line1);
        radbtnMainLine2 = (RadioButton) findViewById(R.id.radbtn_main_line2);
        radbtnMainLine3 = (RadioButton) findViewById(R.id.radbtn_main_line3);
        radbtnMainLine4 = (RadioButton) findViewById(R.id.radbtn_main_line4);
        tvMainTx2 = (TextView) findViewById(R.id.tv_main_tx2);
        radgupMainLine2 = (RadioGroup) findViewById(R.id.radgup_main_line2);
        radbtnMainLine5 = (RadioButton) findViewById(R.id.radbtn_main_line5);
        radbtnMainLine6 = (RadioButton) findViewById(R.id.radbtn_main_line6);
        radbtnMainLine7 = (RadioButton) findViewById(R.id.radbtn_main_line7);
        radbtnMainLine8 = (RadioButton) findViewById(R.id.radbtn_main_line8);
        tvMainTx3 = (TextView) findViewById(R.id.tv_main_tx3);
        radgupMainLine3 = (RadioGroup) findViewById(R.id.radgup_main_line3);
        radbtnMainLine9 = (RadioButton) findViewById(R.id.radbtn_main_line9);
        radbtnMainLine10 = (RadioButton) findViewById(R.id.radbtn_main_line10);
        radbtnMainLine11 = (RadioButton) findViewById(R.id.radbtn_main_line11);
        radbtnMainLine12 = (RadioButton) findViewById(R.id.radbtn_main_line12);
        tvMainTx4 = (TextView) findViewById(R.id.tv_main_tx4);
        radgupMainLine4 = (RadioGroup) findViewById(R.id.radgup_main_line4);
        radbtnMainLine13 = (RadioButton) findViewById(R.id.radbtn_main_line13);
        radbtnMainLine14 = (RadioButton) findViewById(R.id.radbtn_main_line14);
        radbtnMainLine15 = (RadioButton) findViewById(R.id.radbtn_main_line15);
        radbtnMainLine16 = (RadioButton) findViewById(R.id.radbtn_main_line16);
        btnMainSub = (Button) findViewById(R.id.btn_main_sub);
        tvMainTx5 = (TextView) findViewById(R.id.tv_main_tx5);
    }
}